package com.sharer.last.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 评论类型枚举
 *
 * @ClassName CommentTypeEnum
 * @Author WangJin
 * @Date 2023/6/15 16:21
 * @Description
 * @Version 1.0
 */
@Getter
public enum CommentTypeEnum {
    UNKNOWN(0, "UNKNOWN", "UNKNOWN"),
    BLOG(1, "", ""),
    ABOUT(2, "关于我", "/about"),
    FRIEND(3, "友人帐", "/friends"),
    ;
    private Integer code;
    private String  title;
    private String  path;

    private static final Map<Integer, String> STATUS_MAP = new HashMap<>();

    static {
        for (CommentTypeEnum aEnum : CommentTypeEnum.values()) {
            STATUS_MAP.put(aEnum.getCode(), aEnum.getTitle());
        }
    }

    CommentTypeEnum(Integer code, String title, String path) {
        this.code = code;
        this.title = title;
        this.path = path;
    }

    public static CommentTypeEnum getEnum(Integer code) {
        for (CommentTypeEnum aEnum : CommentTypeEnum.values()) {
            if (aEnum.getCode().equals(code)) {
                return aEnum;
            }
        }
        return CommentTypeEnum.UNKNOWN;
    }
}
